package com.icinfo.cloud.provider.punish.service.impl;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.icinfo.cloud.provider.common.utils.HeaderUtil;
import com.icinfo.cloud.provider.punish.common.documentdataload.dto.CaseDataQueryDto;
import com.icinfo.cloud.provider.punish.service.ICloseArchivingService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseMainDetailInfoCommonVo;
import com.icinfo.cloud.provider.punish.ucase.closearchiving.dto.CaseCloseArchivingDto;
import com.icinfo.cloud.provider.punish.ucase.closearchiving.vo.CaseCloseArchivingEchoVo;
import com.icinfo.framework.common.web.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author ChenHan
 * @date 2022/12/5 16:28
 **/
@Service
public class ICloseArchivingServiceImpl implements ICloseArchivingService {

    @Value("${tzService.url}")
    private String url;

    /**
     * 【V1.0.0】描述：保存结案归档信息
     *
     * @param caseCloseArchivingDto
     * @return
     * @author 陈汉
     * @date 2022年12月5日16:26:14
     */
    @Override
    public Result<String> saveCloseInfo(CaseCloseArchivingDto caseCloseArchivingDto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
        String param = JSON.toJSONString(caseCloseArchivingDto);
        String response = HttpUtil.createPost(url.concat("/close/closeArchiving")).addHeaders(headers).body(param).execute().body();
        Result<String> result = JSON.parseObject(response, Result.class);
        return result;
    }

    /**
     * 结案归档 回显
     *
     * @param caseCloseArchivingDto
     * @return
     * @author 陈汉
     * @date 2022年12月5日16:26:14
     */
    @Override
    public Result<CaseCloseArchivingEchoVo> closeArchivingEcho(CaseCloseArchivingDto caseCloseArchivingDto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
        String param = JSON.toJSONString(caseCloseArchivingDto);
        String response = HttpUtil.createPost(url.concat("/close/closeArchivingEcho")).addHeaders(headers).body(param).execute().body();
        Result<CaseCloseArchivingEchoVo> result = JSON.parseObject(response, Result.class);
        return result;
    }

    /**
     * 描述：获取案件基础信息
     *
     * @param queryDto
     * @return
     * @author 陈汉
     * @date 2022年12月5日16:55:46
     */
    @Override
    public Result<CaseMainDetailInfoCommonVo> getCaseMainInfo(CaseDataQueryDto queryDto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
        String param = JSON.toJSONString(queryDto);
        String response = HttpUtil.createPost(url.concat("/punish/docdataload/documentdataload/getCaseMainInfo")).addHeaders(headers).body(param).execute().body();
        Result<CaseMainDetailInfoCommonVo> result = JSON.parseObject(response, Result.class);
        return result;
    }
}
